<template>
  <div>
    <p>你要购买商品的数量：{{count}}</p>
    <button v-on:click="count=count+1">+1</button>
    <button v-on:click="addFn">+1</button>
    <button v-on:click="addCountFn(5)">+5</button>
    <button @click='subFn'>减少1件</button>
  </div>
</template>

<script>
export default {
  data () {
    return {
      count:1
    }
  },
  // 定义函数
  methods: {
    addFn(){//this指向的是export default 的{}
    //data函数会把对象挂到当前组件的对象上
      this.count ++
    },
    addCountFn(num){
      this.count = this.count + 5
    },
    subFn(){
      this.count--
    }
  }
}
</script>

<style>

</style>